
# A3b_plot_entry
#==============================================================================
  
# Description: This code creates the plot for the entry-only case

rm(list = ls())

library('data.table')
library('stargazer')
library('ggplot2')


diff_data <- fread("results/price_index/diff_actual.csv")

income_data <- fread(file = "Income.csv")

Reg_P_summary <- lm(diff ~ 0 + as.factor(declarant), data = diff_data)
print(summary(Reg_P_summary))

# Format Data to Save Regression Output

declarant <- unique(diff_data$declarant)
declarant <- sort(declarant)

income_data <- fread(file = "Income.csv")

# Save Regression

output <- merge(income_data, data.table(declarant, Reg_P_summary$coefficients), by = "declarant")
colnames(output) <- c(colnames(output)[1:4], "FE_declarant")
write.csv(file = "results/2_price_index/diff_Price_Index_actual.csv", output)



